<?php

/*
	工单列表（工作人员）
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'mylist';
$return=array();
$return['types']=array(
	'1'=>'常规模型',
	'2'=>'售后维护',
	'3'=>'服务模型',
	'6'=>'定制开发',
	'8'=>'参与活动',
);
$return['statuss']=array(
	'0'=>'待处理',
	'1'=>'处理中',
	'2'=>'已处理',
	'3'=>'交付完成',
	'4'=>'交付不通过',
	'5'=>'回炉状态',
	'6'=>'回炉不通过',
	'7'=>'进入初测',
	'8'=>'初测不通过',
);
$return['msgs']=array(
	'0'=>'无',
	'1'=>'有新的',
);
$tabs=array(
			array('op'=>'mylist','title'=>'我的工单'),
			array('op'=>'edit','title'=>'添加工单'),
			array('op'=>'help','title'=>'赚积分'),
			array('op'=>'diy','title'=>'我的定制需求'),
			array('op'=>'diyedit','title'=>'添加定制需求'),
			//array('op'=>'lookdiy','title'=>'我是开发者'),
			array('op'=>'yuding','title'=>'我发起的众筹'),
			array('op'=>'yudingedit','title'=>'添加众筹'),
			array('op'=>'kefu','title'=>'联系客服'),
);
if($_RQ['op']=='mylist'){
	$params=array('type <>'=>6,'uniacid'=>$_SESSION['one_uniacid']?:$_SESSION['uniacid']);
	//类型。1表示开发工单，2表示bug修复工单，3表示客户异常问题处理
	if(!empty($_RQ['groupid'])){
		$params['groupid']=intval($_RQ['groupid']);
		$return['params']['groupid']=$_RQ['groupid'];
	}
	if(!empty($_RQ['type'])){
		$params['type']=intval($_RQ['type']);
		$return['params']['type']=intval($_RQ['type']);
	}
	//状态。0表示待处理。1表示处理中。2表示处理完毕待审核。3表示审核通过。
	if(!empty($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	if(!empty($_RQ['page'])){
		$params['page']=intval($_RQ['page']);
		$return['params']['page']=$_RQ['page'];
	}
	if(!empty($_RQ['id'])){
		$params['id']=intval($_RQ['id']);
		$return['params']['id']=$_RQ['id'];
	}
	//领取人
	if(!empty($_RQ['getmid'])){
		//$getmid = pdo_getcolumn('jy_workline_worker',array('id'=>intval($_RQ['getmid'])),'mid');
		$params['getmid']=intval($_RQ['getmid']);
		$return['params']['getmid']=$_RQ['getmid'];
	}
	if($_RQ['complete_time']){
		$time_range=cfc('tools')->base64_decode($_RQ['complete_time'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['complete_time']=$time_range;
		$params['complete_time between']=array($time_range['tstart'],$time_range['tend']);
	}
	//工单名称
	if(!empty($_RQ['title'])){
		$params['title']=trim($_RQ['title']);
		$return['params']['title']=$_RQ['title'];
	}
	$return=cloud_request('cloud.workerline.mylist',$params);
	foreach($return['list'] as &$item){
		$item['plugintitle']=pdo_getcolumn('core_plugins',array('name'=>$item['pluginname']),'title');
		$item['plugintitle']=$item['plugintitle']?:'系统';
		$item['shownew']=$item['msgnum']>0?1:0;
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'[<red>温馨提示</red>]：
		</br>此工单，<red>超级管理员</red>才可见；用于发工单给程序开发者（并非站点发起工单给管理员）；
		</br>有任何使用问题，都可以发工单，技术人员会在24小时内回复处理的！紧急问题可以咨询在线客服（移步应用市场--扫客服二维码！）！
		</br>微信如何收到《<red>工单消息提醒</red>》？赚积分--》关注微信公众号--》微信粉丝绑定本站点《云服务账户》--即可接收《工单消息提醒》
		','edit'=>false,'delall'=>false,'del_one'=>false,'list'=>array(
			array('name'=>'id','title'=>'工单ID','type'=>'string'),
			array('name'=>'title','title'=>'工单名称','type'=>'string'),
			array('type'=>'string','name'=>'plugintitle','title'=>'所属插件'),
			array('name'=>'type','title'=>'工单分类','type'=>'radio','options'=>'types'),
			array('name'=>'status','title'=>'工单状态','type'=>'radio','options'=>'statuss'),
			//array('name'=>'receive_type','title'=>'领取方式','type'=>'radio','options'=>'receive_types'),
			array('name'=>'receive_time','title'=>'处理时间','type'=>'time'),
			array('name'=>'createtime','title'=>'提交时间','type'=>'time'),
			array('name'=>'pay_fee','title'=>'已付费','type'=>'string'),
			//array('name'=>'complete_time','title'=>'完成时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'modal','op'=>'pay','title'=>'付费处理','show'=>array('status'=>array(0,1,2))),
			array('type'=>'href','op'=>'look','title'=>'查看','shownew'=>1,'show'=>array('status !='=>4)),
			array('type'=>'modal','op'=>'uptask','title'=>'重新提交','show'=>array('status'=>2)),
			array('type'=>'post','op'=>'upend','title'=>'确认已解决','show'=>array('status'=>array(1,2))),
			array('type'=>'href','op'=>'edit','title'=>'编辑','show'=>array('status !='=>4)),
			array('type'=>'post','op'=>'del','title'=>'删除'),
		)),
		'search'=>array(
			array('type'=>'string','width'=>15,'name'=>'id','title'=>'工单ID'),
			array('name'=>'type','width'=>15,'title'=>'工单分类','type'=>'radio','options'=>'types'),
			array('type'=>'radio','width'=>15,'name'=>'status','title'=>'工单状态','options'=>'statuss'),
			array('type'=>'string','width'=>15,'name'=>'title','title'=>'工单名称'),
			array('type'=>'time_range','width'=>18,'title'=>'完成时间','name'=>'complete_time','help'=>''),
		),
	);
	$return['htmls']=$htmls;
	exi($return);
}

if($_RQ['op']=='look'){
	$id=intval($_RQ['id']);
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=intval($post['id']);
		if($post['subimg']){
			foreach($post['subimg'] as &$v){
				$v=tomedia($v);
			}
		}
		if($post['status']>=2){
			//exi('已处理完的问题，不能再追加问题','error');
		}
		$tcplog = array(
			'id'=>$id,
			'msg'=>trim($post['sublog']),
			'image'=>ijson_encode($post['subimg']),
			'file'=>$post['file']?tomedia($post['file']):'',
			'subtype'=>$post['subtype'],
			'createtime'=>TIMESTAMP
		);
		cloud_request('cloud.workerline.uplog',$tcplog);
		exi('提交成功！','','goback');
	}
	if(!$id){
		exi('请先选择工单！','error');
	}
	$return=cloud_request('cloud.workerline.look',array('id'=>$id,'uniacid'=>$_SESSION['one_uniacid']?:$_SESSION['uniacid']));
	$return=json_decode($return,true);
	$return['item']['result']=$return['item']['result']?:'无';
	$return['item']['plugintitle']=pdo_getcolumn('core_plugins',array('name'=>$return['item']['pluginname']),'title');
	$return['item']['plugintitle']=$return['item']['plugintitle']?:'系统';
	$return['item']['logs']=$return['log'];
	$return['htmls']=array(
		'type'=>'edit',
		'tabs'=>array(
			array('op'=>'mylist','title'=>'返回工单列表'),
		),
		'desc'=>'工单信息',
		'edit'=>array(
			array('type'=>'string','read'=>true,'name'=>'title','title'=>'工单名称'),
			array('type'=>'string','read'=>true,'name'=>'plugintitle','title'=>'所属插件'),
			//array('type'=>'string','name'=>'cycle','title'=>'工单周期（天）'),
			//array('type'=>'radio','name'=>'groupid','title'=>'工单分组','option_title'=>'title','options'=>'groups'),
			array('type'=>'radio','read'=>true,'name'=>'type','title'=>'工单类型','options'=>'types'),
			array('type'=>'radio','read'=>true,'name'=>'default_type','title'=>'小分类','options'=>'default_type','show'=>array('type'=>1)),
			//array('type'=>'radio','name'=>'bug_type','title'=>'小分类','options'=>'bug_type','show'=>array('type'=>2)),
			//array('type'=>'radio','name'=>'service_type','title'=>'小分类','options'=>'service_type','show'=>array('type'=>3)),
			//array('type'=>'text','read'=>true,'name'=>'content','title'=>'工单内容'),
			//array('type'=>'images','read'=>true,'name'=>'image','title'=>'工单截图'),
			array('type'=>'string','name'=>'web','title'=>'网站资料','show'=>array('type'=>3)),
			array('type'=>'string','name'=>'ftp','title'=>'ftp','show'=>array('type'=>3)),
			array('type'=>'string','name'=>'db','title'=>'数据库资料','show'=>array('type'=>3)),
			array('type'=>'logs','name'=>'logs','title'=>'处理信息'),
			array('type'=>'text','name'=>'sublog','title'=>'追加问题','help'=>'已处理完的问题，如果还未处理，可以再追加问题'),
			array('type'=>'images','name'=>'subimg','title'=>'追加图片'),
			array('type'=>'upfile','name'=>'file','title'=>'追加附件'),
			array('type'=>'radio','name'=>'subtype','title'=>'处理情况','options'=>'subtypes'),
		),
	);
	$return['subtypes']=array('追问','已解决');
	exi($return);
}
if($_RQ['op']=='edit'){
	if($_RQ['postdata']){
		$post=get_postdata();
		if(!$post['title']){
			exi('请输入标题','error');
		}
		if(!$post['type']){
			exi('请选择工单模型','error');
		}
		if(!$post['content']){
			exi('请填写内容','error');
		}
		if(!$post['id']){
			$post['uniacid']=$_SESSION['one_uniacid']?:$_SESSION['uniacid'];
		}
		if(!$post['isplugin']){
			$post['pluginname']='core';
		}
		if($post['isplugin'] && !$post['pluginname'] && $post['style']!=4){
			exi('请选择所属插件！','error');
		}
		if($post['image']){
			foreach($post['image'] as &$v){
				$v=tomedia($v);
			}
		}
		$post['file']=$post['file']?tomedia($post['file']):'';
		cloud_request('cloud.workerline.post',$post);
		exi('操作成功！','','goback');
	}
	$id=intval($_RQ['id']);
	$return=cloud_request('cloud.workerline.edit',array('id'=>$id));
	$return['htmls']=array(
		'type'=>'edit',
		'tabs'=>array(
			array('op'=>'mylist','title'=>'返回工单列表'),
		),
		'desc'=>'设置工单信息',
		'edit'=>array(
			array('type'=>'string','name'=>'title','title'=>'工单名称'),
			array('type'=>'switch','name'=>'isplugin','title'=>'插件问题？','help'=>'默认是框架问题，如果是插件问题，请选择！'),
			array('type'=>'radio','name'=>'style','title'=>'插件类型','options'=>'styles'),
			array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins1','show'=>array('style'=>1)),
			array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins2','show'=>array('style'=>2)),
			array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins3','show'=>array('style'=>3)),
			//array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins4','show'=>array('style'=>4)),
			array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins5','show'=>array('style'=>5)),
			array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins6','show'=>array('style'=>6)),
			array('type'=>'switch','name'=>'jiaji','title'=>'是否加急'),
			//array('type'=>'string','name'=>'cycle','title'=>'工单周期（天）'),
			//array('type'=>'select','name'=>'groupid','title'=>'工单分组','option_title'=>'title','options'=>'groups'),
			array('type'=>'radio','name'=>'type','title'=>'工单类型','options'=>'types'),
			array('type'=>'radio','name'=>'default_type','title'=>'小分类','options'=>'default_type','show'=>array('type'=>1)),
			array('type'=>'radio','name'=>'bug_type','title'=>'小分类','options'=>'bug_type','show'=>array('type'=>2)),
			array('type'=>'radio','name'=>'service_type','title'=>'小分类','options'=>'service_type','show'=>array('type'=>3)),
			array('type'=>'text','name'=>'content','title'=>'工单内容'),
			array('type'=>'images','name'=>'image','title'=>'工单截图'),
			array('type'=>'upfile','name'=>'file','title'=>'追加附件'),
			array('type'=>'text','name'=>'web','title'=>'网站资料','show'=>array('type'=>3)),
			array('type'=>'text','name'=>'ftp','title'=>'ftp','show'=>array('type'=>3)),
			array('type'=>'text','name'=>'db','title'=>'数据库资料','show'=>array('type'=>3)),
		),
	);
	$return['styles']=get_plugin_styles();
	$plugins=pdo_getall('core_plugins',array('hide'=>0),array('name','title','style'),'name');
	$return['plugins']=array();
	foreach($plugins as $item){
		$return['plugins'.$item['style']][$item['name']]=$item['title'];
	}
	exi($return);
}
if($_RQ['op']=='diy'){
	$params=array('uniacid'=>$_SESSION['one_uniacid']?:$_SESSION['uniacid'],'type'=>6);
	//类型。1表示开发工单，2表示bug修复工单，3表示客户异常问题处理
	if(!empty($_RQ['groupid'])){
		$params['groupid']=intval($_RQ['groupid']);
		$return['params']['groupid']=$_RQ['groupid'];
	}
	//状态。0表示待处理。1表示处理中。2表示处理完毕待审核。3表示审核通过。
	if(!empty($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	if(!empty($_RQ['page'])){
		$params['page']=intval($_RQ['page']);
		$return['params']['page']=$_RQ['page'];
	}
	//领取人
	if(!empty($_RQ['getmid'])){
		//$getmid = pdo_getcolumn('jy_workline_worker',array('id'=>intval($_RQ['getmid'])),'mid');
		$params['getmid']=intval($_RQ['getmid']);
		$return['params']['getmid']=$_RQ['getmid'];
	}
	if($_RQ['complete_time']){
		$time_range=cfc('tools')->base64_decode($_RQ['complete_time'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['complete_time']=$time_range;
		$params['complete_time between']=array($time_range['tstart'],$time_range['tend']);
	}
	//工单名称
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$return=cloud_request('cloud.workerline.mylist',$params);
	foreach($return['list'] as &$item){
		$item['shownew']=$item['msgnum']>0?1:0;
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'[<red>温馨提示</red>]：有任何定制需求，都可以发定制，技术人员会在24小时内回复报价的！紧急问题可以咨询在线客服（移步应用市场--扫客服二维码！）！','edit'=>false,'delall'=>false,'del_one'=>false,'list'=>array(
			array('name'=>'title','title'=>'定制名称','type'=>'string'),
			array('name'=>'status','title'=>'定制状态','type'=>'radio','options'=>'statuss'),
			array('name'=>'getuser','title'=>'领取人','type'=>'string'),
			array('name'=>'receive_time','title'=>'处理时间','type'=>'time'),
			array('name'=>'createtime','title'=>'提交时间','type'=>'time'),
			array('name'=>'price','title'=>'期望价格','type'=>'string'),
			array('name'=>'pay_fee','title'=>'已付费','type'=>'string'),
			//array('name'=>'complete_time','title'=>'完成时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'modal','op'=>'diypay','title'=>'支付费用','show'=>array('status'=>array(0,1,2))),
			array('type'=>'href','op'=>'look','title'=>'查看','shownew'=>1,'show'=>array('status !='=>4)),
			array('type'=>'modal','op'=>'uptask','title'=>'重新提交','show'=>array('status'=>2)),
			array('type'=>'post','op'=>'upend','title'=>'确认已解决','show'=>array('status'=>array(1,2))),
			array('type'=>'post','op'=>'quxiao_work1','title'=>'重置领取者','show'=>array('getmid >'=>0)),
			array('type'=>'href','op'=>'diyedit','title'=>'编辑','show'=>array('status !='=>4)),
			array('type'=>'post','op'=>'del','title'=>'删除'),
		)),
		'search'=>array(
			array('type'=>'radio','width'=>15,'name'=>'status','title'=>'定制状态','options'=>'statuss'),
			array('type'=>'string','width'=>15,'name'=>'title','title'=>'定制名称'),
			array('type'=>'time_range','width'=>18,'title'=>'完成时间','name'=>'complete_time','help'=>''),
		),
	);
	$return['user_types']=array('进云官方','第三方开发者');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='diyedit'){
	if($_RQ['postdata']){
		$post=get_postdata();
		if(!$post['title']){
			exi('请输入定制标题','error');
		}
		if(!$post['content']){
			exi('请填写定制内容','error');
		}
		if(!$post['getuser_type']){
			exi('请勾选谁《支持领取》您的任务！','error');
		}
		if($post['image']){
			foreach($post['image'] as &$v){
				$v=tomedia($v);
			}
		}
		$post['type']=6;
		$post['file']=$post['file']?tomedia($post['file']):'';
		cloud_request('cloud.workerline.post',$post);
		exi('操作成功！','','diy');
	}
	$id=intval($_RQ['id']);
	$return=cloud_request('cloud.workerline.edit',array('id'=>$id));
	$return['user_types']=array('进云官方','第三方开发者');
	$return['htmls']=array(
		'type'=>'edit',
		'tabs'=>array(
			array('op'=>'diy','title'=>'返回定制列表'),
		),
		'desc'=>'设置定制信息',
		'edit'=>array(
			array('type'=>'tip','title'=>'
			[<red>定制说明</red>]：进云有着强大的智能化基因，独创JYS机制，方便一对多应用端开发！独创乐高机制，可以快速定制不同的场景！定制开发成本是普通开发的1/5。
			</br>1、先提交定制的需求说明，技术会评估报价，我们会在一个工作日内回复（报价，周期等）；
			</br>2、感觉各方面合适，您只需按报价提交费用即可；
			</br>3、您提供微信号，技术员会加您微信；
			</br>4、后续开发沟通服务，都在微信端完成；
			</br>5、初步完成，发“插件安装码”给客户安装测试；
			'),
			array('type'=>'string','name'=>'title','title'=>'定制名称'),
			//array('type'=>'radio','name'=>'style','title'=>'插件类型','options'=>'styles'),
			array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins1','show'=>array('style'=>1)),
			array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins2','show'=>array('style'=>2)),
			array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins3','show'=>array('style'=>3)),
			//array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins4','show'=>array('style'=>4)),
			array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins5','show'=>array('style'=>5)),
			array('type'=>'radio','name'=>'pluginname','title'=>'所属插件','option_title'=>'title','option_value'=>'name','options'=>'plugins6','show'=>array('style'=>6)),

			array('type'=>'switch','name'=>'jiaji','title'=>'是否加急'),
			array('name'=>'price','title'=>'期望价格','type'=>'string'),
			array('name'=>'getuser_type','title'=>'支持领取','type'=>'checkbox','options'=>'user_types'),
			array('type'=>'text','name'=>'content','title'=>'定制需求说明'),
			array('type'=>'images','name'=>'image','title'=>'定制需求配图'),
			array('type'=>'upfile','name'=>'file','title'=>'追加附件'),
		),
	);
	$return['styles']=get_plugin_styles();
	$plugins=pdo_getall('core_plugins',array('hide'=>0),array('name','title','style'),'name');
	$return['plugins']=array();
	foreach($plugins as $item){
		$return['plugins'.$item['style']][$item['name']]=$item['title'];
	}
	exi($return);
}
if($_RQ['op']=='lookdiy'){
	$params=array('type'=>6);
	//状态。0表示待处理。1表示处理中。2表示处理完毕待审核。3表示审核通过。
	if(!empty($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	if(!empty($_RQ['page'])){
		$params['page']=intval($_RQ['page']);
		$return['params']['page']=$_RQ['page'];
	}
	if($_RQ['complete_time']){
		$time_range=cfc('tools')->base64_decode($_RQ['complete_time'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['complete_time']=$time_range;
		$params['complete_time between']=array($time_range['tstart'],$time_range['tend']);
	}
	//工单名称
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$return=cloud_request('cloud.workerline.lookdiy',$params);
	foreach($return['list'] as &$item){
		$item['shownew']=$item['msgnum']>0?1:0;
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'mylist','title'=>'返回工单列表'),
			array('op'=>'lookdiy','title'=>'客户市场'),
			array('op'=>'mylookdiy','title'=>'我的接单'),
		),
		'list'=>array('data'=>'list','tip'=>'[<red>温馨提示</red>]：可以先查看客户定制(支持第三方开发者接单)，如果想接定制，可以先接单--》在线咨询--》线下微信沟通！','edit'=>false,'delall'=>false,'del_one'=>false,'list'=>array(
			array('name'=>'title','title'=>'定制名称','type'=>'string'),
			array('name'=>'status','title'=>'定制状态','type'=>'radio','options'=>'statuss'),
			array('name'=>'getuser','title'=>'领取人','type'=>'string'),
			array('name'=>'receive_time','title'=>'处理时间','type'=>'time'),
			array('name'=>'createtime','title'=>'提交时间','type'=>'time'),
			array('name'=>'price','title'=>'期望价格','type'=>'string'),
			array('name'=>'pay_fee','title'=>'已付费','type'=>'string'),
			//array('name'=>'complete_time','title'=>'完成时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'post','op'=>'get_work','title'=>'领取任务','show'=>array('getmid'=>0)),
			array('type'=>'modal','op'=>'lookinfo','title'=>'需求介绍','show'=>array('getmid'=>0)),
			//array('type'=>'post','op'=>'get_work','title'=>'取消任务'),
		)),
		'search'=>array(
			array('type'=>'radio','width'=>15,'name'=>'status','title'=>'定制状态','options'=>'statuss'),
			array('type'=>'string','width'=>15,'name'=>'title','title'=>'定制名称'),
			array('type'=>'time_range','width'=>18,'title'=>'完成时间','name'=>'complete_time','help'=>''),
		),
	);
	$return['user_types']=array('进云官方','第三方开发者');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='mylookdiy'){
	$params=array('type'=>6);
	//状态。0表示待处理。1表示处理中。2表示处理完毕待审核。3表示审核通过。
	if(!empty($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	if(!empty($_RQ['page'])){
		$params['page']=intval($_RQ['page']);
		$return['params']['page']=$_RQ['page'];
	}
	if($_RQ['complete_time']){
		$time_range=cfc('tools')->base64_decode($_RQ['complete_time'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['complete_time']=$time_range;
		$params['complete_time between']=array($time_range['tstart'],$time_range['tend']);
	}
	//工单名称
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$return=cloud_request('cloud.workerline.mylookdiy',$params);
	foreach($return['list'] as &$item){
		$item['shownew']=$item['msgnum']>0?1:0;
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'mylist','title'=>'返回工单列表'),
			array('op'=>'lookdiy','title'=>'客户市场'),
			array('op'=>'mylookdiy','title'=>'我的接单'),
		),
		'list'=>array('data'=>'list','tip'=>'[<red>温馨提示</red>]：可以先查看客户定制，如果想接定制，可以先接单--》在线咨询--》线下微信沟通！','edit'=>false,'delall'=>false,'del_one'=>false,'list'=>array(
			array('name'=>'title','title'=>'定制名称','type'=>'string'),
			array('name'=>'status','title'=>'定制状态','type'=>'radio','options'=>'statuss'),
			array('name'=>'getuser','title'=>'领取人','type'=>'string'),
			array('name'=>'receive_time','title'=>'处理时间','type'=>'time'),
			array('name'=>'createtime','title'=>'提交时间','type'=>'time'),
			array('name'=>'price','title'=>'期望价格','type'=>'string'),
			array('name'=>'pay_fee','title'=>'已付费','type'=>'string'),
			//array('name'=>'complete_time','title'=>'完成时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'href','op'=>'getlook','title'=>'查看任务','show'=>array('status !='=>4)),
			array('type'=>'post','op'=>'quxiao_work','title'=>'取消任务'),
		)),
		'search'=>array(
			array('type'=>'radio','width'=>15,'name'=>'status','title'=>'定制状态','options'=>'statuss'),
			array('type'=>'string','width'=>15,'name'=>'title','title'=>'定制名称'),
			array('type'=>'time_range','width'=>18,'title'=>'完成时间','name'=>'complete_time','help'=>''),
		),
	);
	$return['user_types']=array('进云官方','第三方开发者');
	$return['htmls']=$htmls;
	exi($return);
}
//查看定制的
if($_RQ['op']=='lookinfo'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择工单！','error');
	}
	$return=cloud_request('cloud.workerline.lookinfo',array('id'=>$id,'uniacid'=>$_SESSION['one_uniacid']?:$_SESSION['uniacid']));
	$return=json_decode($return,true);
	$return['htmls']=array(
		'type'=>'look',
		'desc'=>'定制信息',
		'look'=>array(
			array('type'=>'tip','title'=>'[温馨提示]：未领取任务，只能查看简单的《需求介绍》'),
			array('type'=>'string','name'=>'title','title'=>'定制名称'),
			array('type'=>'text','name'=>'content','title'=>'需求介绍'),
		),
	);
	exi($return);
}
if($_RQ['op']=='getlook'){
	$id=intval($_RQ['id']);
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=intval($post['id']);
		if($post['subimg']){
			foreach($post['subimg'] as &$v){
					$v=tomedia($v);
			}
		}
		if($post['status']>=2){
			//exi('已处理完的问题，不能再追加问题','error');
		}
		$tcplog = array(
			'id'=>$id,
			'uniacid'=>$_SESSION['one_uniacid']?:$_SESSION['uniacid'],
			'msg'=>trim($post['sublog']),
			'image'=>ijson_encode($post['subimg']),
			'file'=>$post['file']?tomedia($post['file']):'',
			'subtype'=>$post['subtype'],
			'createtime'=>TIMESTAMP
		);
		cloud_request('cloud.workerline.uplog',$tcplog);
		exi('提交成功！','','goback');
	}
	if(!$id){
		exi('请先选择工单！','error');
	}
	$return=cloud_request('cloud.workerline.look',array('id'=>$id,'uniacid'=>$_SESSION['one_uniacid']?:$_SESSION['uniacid']));
	$return=json_decode($return,true);
	$return['item']['result']=$return['item']['result']?:'无';
	$return['item']['plugintitle']=pdo_getcolumn('core_plugins',array('name'=>$return['item']['pluginname']),'title');
	$return['item']['plugintitle']=$return['item']['plugintitle']?:'系统';
	$return['item']['logs']=$return['log'];
	$jsname='客户';
	$return['htmls']=array(
		'type'=>'edit',
		'tabs'=>array(
			array('op'=>'mylist','title'=>'返回工单列表'),
		),
		'desc'=>'工单信息',
		'edit'=>array(
			array('type'=>'string','read'=>true,'name'=>'title','title'=>'工单名称'),
			array('type'=>'string','read'=>true,'name'=>'plugintitle','title'=>'所属插件'),
			array('type'=>'radio','read'=>true,'name'=>'type','title'=>'工单类型','options'=>'types'),
			array('type'=>'radio','read'=>true,'name'=>'default_type','title'=>'小分类','options'=>'default_type','show'=>array('type'=>1)),
			array('type'=>'logs','name'=>'logs','jsname'=>$jsname,'title'=>'处理信息'),
			array('type'=>'text','name'=>'sublog','title'=>'追加问题','help'=>'已处理完的问题，如果还未处理，可以再追加问题'),
			array('type'=>'images','name'=>'subimg','title'=>'追加图片'),
			array('type'=>'upfile','name'=>'file','title'=>'追加附件'),
			array('type'=>'radio','name'=>'subtype','title'=>'处理情况','options'=>'subtypes'),
		),
	);
	$return['subtypes']=array('反馈','追问','处理提交');
	$return['post']=array('id'=>$id,'subtype'=>'0');
	exi($return);
}
if($_RQ['op']=='get_work'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择任务！','error');
	}
	cloud_request('cloud.workerline.get_work',array('id'=>$id));
	exi('领取成功！','','mylookdiy');
}
if($_RQ['op']=='quxiao_work1'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择任务！','error');
	}
	cloud_request('cloud.workerline.quxiao_work',array('id'=>$id));
	exi('重置领取者成功！','','diy');
}
if($_RQ['op']=='quxiao_work'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择任务！','error');
	}
	cloud_request('cloud.workerline.quxiao_work',array('id'=>$id));
	exi('取消成功！','','mylookdiy');
}
//指派工单
if($_RQ['op']=='staff'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=intval($post['id']);
		$item=pdo_get('jy_workline_task',array('id'=>$id),array('id','title','tcpid'));
		if($item['setmid'] == $_SESSION['uid']){
			$receive_type = 1;
		}else{
			$receive_type = 3;
		}
		$getmid = pdo_getcolumn('jy_workline_worker',array('id'=>intval($post['getmid'])),'mid');
		$data=array(
			'status'=>1,
			'receive_type'=>$receive_type,//1表示发布者指派
			'receive_time'=>TIMESTAMP,
			'getmid'=>$getmid,
		);
		if(!$id){
			exi('请先选择工单！','error');
		}
		if(!$data['getmid']){
			exi('请先选择处理人！','error');
		}
		pdo_update('jy_workline_task',$data,array('id'=>$id));
		exi('操作成功！','','list');
	}
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择工单！','error');
	}
	$item=pdo_get('jy_workline_task',array('id'=>$id),array('id','title','tcpid'));
	if(!$item){
		exi('指定工单不存在！','error');
	}
	$return['workers']=pdo_getall('jy_workline_worker',array('uniacid'=>0));
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'edit',
		'desc'=>'指派特定人员处理工单',
		'edit'=>array(
			array('type'=>'string','name'=>'title','title'=>'工单名称','read'=>true),
			array('type'=>'select','name'=>'getmid','title'=>'指派处理人','option_title'=>'name','options'=>'workers'),
		),
	);
	exi($return);
}
if($_RQ['op']=='pay'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$post['fee']=$post['feetype']?50:$post['fee'];
		if($post['fee']<10){
			exi('费用金额不能小于10！','error');
		}
		cloud_request('cloud.workerline.pay',$post);
		exi('操作成功！','','/account.workerline/mylist/');
	}
	$id=intval($_RQ['id']);
	$return=cloud_request('cloud.workerline.edit',array('id'=>$id));
	$return['item']['feetype']=0;
	$return['htmls']=array(
		'type'=>'edit',
		'desc'=>'付费处理？',
		'edit'=>array(
			array('type'=>'string','name'=>'title','title'=>'工单名称','read'=>true),
			array('type'=>'switch','name'=>'feetype','title'=>'加急处理？','help'=>'[温馨提示]：默认加急处理费用是：50元'),
			array('type'=>'unitstring','name'=>'fee','title'=>'输入付费金额','unit'=>'元','help'=>'[温馨提示]：默认加急处理费用是：50元；其他特殊问题处理（非BUG），按工单技术员报价收费！','show'=>array('feetype'=>0)),
		),
	);
	exi($return);
}
if($_RQ['op']=='diypay'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$post['fee']=$post['feetype']?50:$post['fee'];
		if($post['fee']<10){
			exi('费用金额不能小于10！','error');
		}
		cloud_request('cloud.workerline.pay',$post);
		exi('操作成功！','','/account.workerline/mylist/');
	}
	$id=intval($_RQ['id']);
	$return=cloud_request('cloud.workerline.edit',array('id'=>$id));
	$return['item']['feetype']=0;
	$return['htmls']=array(
		'type'=>'edit',
		'desc'=>'支付定制费用？',
		'edit'=>array(
			array('type'=>'string','name'=>'title','title'=>'定制名称','read'=>true),
			array('type'=>'unitstring','name'=>'fee','title'=>'输入付费金额','unit'=>'元','help'=>'[温馨提示]：请按技术员报价付费！','show'=>array('feetype'=>0)),
		),
	);
	exi($return);
}
if($_RQ['op']=='uptask'){
	if($_RQ['postdata']){
		$post=get_postdata();
		if(!isset($post['way'])){
			exi('请选择重新提交的原因！','error');
		}
		cloud_request('cloud.workerline.uptask',$post);
		exi('操作成功！','','/account.workerline/mylist/');
	}
	$id=intval($_RQ['id']);
	$return=cloud_request('cloud.workerline.edit',array('id'=>$id));
	$return['htmls']=array(
		'type'=>'edit',
		'desc'=>'重新提交问题？',
		'edit'=>array(
			array('type'=>'string','name'=>'title','title'=>'工单名称','read'=>true),
			array('type'=>'radio','name'=>'way','title'=>'重新提交的原因？','options'=>'ways'),
		),
	);
	$return['ways']=array('问题未解决','产生新问题','部分未解决');
	exi($return);
}
if($_RQ['op']=='yuding'){
	$params=array('uniacid'=>$_SESSION['one_uniacid']?:$_SESSION['uniacid']);
	//状态。0表示待处理。1表示处理中。2表示处理完毕待审核。3表示审核通过。
	if(!empty($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	if(!empty($_RQ['page'])){
		$params['page']=intval($_RQ['page']);
		$return['params']['page']=$_RQ['page'];
	}
	//名称
	if(!empty($_RQ['title'])){
		$params['title']=trim($_RQ['title']);
		$return['params']['title']=$_RQ['title'];
	}
	$return=cloud_request('cloud.workerline.myyuding',$params);
	foreach($return['list'] as &$item){
		$item['shownew']=$item['msgnum']>0?1:0;
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'[<red>温馨提示</red>]：有任何想定制的应用插件，感觉很有市场需求，可以发起众筹，众筹人数满额后，官方会安排技术定制开发，发起众筹的人有义务跟进定制进度，内测跑通众筹的插件！','edit'=>false,'delall'=>false,'del_one'=>false,'list'=>array(
			array('name'=>'title','title'=>'插件名称','type'=>'string'),
			array('name'=>'price','title'=>'插件上线价格','type'=>'string'),
			array('name'=>'status','title'=>'众筹状态','type'=>'radio','options'=>'yustatuss'),
			array('name'=>'yu_price','title'=>'众筹单价','type'=>'string'),
			array('name'=>'yu_num','title'=>'众筹满额人数','type'=>'string'),
			array('name'=>'is_yunum','title'=>'已定人数','type'=>'string'),
			array('name'=>'createtime','title'=>'提交时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'href','op'=>'yudingedit','title'=>'编辑'),
			array('type'=>'post','op'=>'yudingdel','title'=>'删除','show'=>array('status'=>5)),
		)),
		'search'=>array(
			array('type'=>'radio','width'=>15,'name'=>'status','title'=>'众筹状态','options'=>'yustatuss'),
			array('type'=>'string','width'=>15,'name'=>'title','title'=>'插件名称'),
		),
	);
	$return['yustatuss']=array(
		0=>'已下架',
		1=>'已发布',
		2=>'众筹中',
		3=>'已满员',
		5=>'待审核众筹',
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='yudingedit'){
	if($_RQ['postdata']){
		$post=get_postdata();
		if(!$post['title']){
			exi('请输入插件名称','error');
		}
		if(!$post['yu_num']){
			exi('请输入满员人数','error');
		}
		if(!$post['yu_price']){
			exi('请输入众筹价格','error');
		}
		if(!$post['price']){
			exi('请输入上线价格','error');
		}
		if(!$post['content']){
			exi('请填写定制需求简单说明','error');
		}
		if($post['hdp']){
			foreach($post['hdp'] as &$v){
				$v=tomedia($v);
			}
		}
		$post['pdf']=$post['pdf']?tomedia($post['pdf']):'';
		cloud_request('cloud.workerline.yudingpost',$post);
		exi('操作成功！','','yuding');
	}
	$id=intval($_RQ['id']);
	$return=cloud_request('cloud.workerline.yudingedit',array('id'=>$id));
	if($return['item']['status']==1 || $return['item']['status']==2 || $return['item']['status']==3){
		$isread=true;
	}
	$return['htmls']=array(
		'type'=>'edit',
		'tabs'=>array(
			array('op'=>'yuding','title'=>'返回众筹列表'),
		),
		'desc'=>'设置众筹信息',
		'edit'=>array(
			array('type'=>'tip','title'=>'
			[<red>众筹说明</red>]：有任何想定制的应用插件，感觉很有市场需求，可以发起众筹，众筹人数满额后，官方会安排技术定制开发，发起众筹的人有义务跟进定制进度，内测跑通众筹的插件！
			</br>1、发起插件众筹，设置插件插件上线价，众筹价格，满额人数（<red>插件定制成本=众筹价格*满额人数</red>）；
			</br>2、插件定制费用，自己可以跟进市场行情，对半预估，然后计算众筹价格，满额人数；
			</br>3、平台技术会跟进插件定制需求，判断《发起插件众筹》是否合适；
			</br>4、审核通过后，发起插件众筹会出现在应用市场--插件众筹板块页面；
			</br>5、所有客户可以参与众筹，众筹满员后，不能再参与众筹，只能等等发布上线后，按上线价购买本插件；
			'),
			array('type'=>'string','name'=>'title','title'=>'插件命名'),
			array('name'=>'yu_price','title'=>'众筹价格','type'=>'unitstring','unit'=>'元','read'=>$isread,'help'=>'(<red>已上线的不能修改</red>)，众筹价格越低，客户参与众筹热点更高！'),
			array('name'=>'yu_num','title'=>'众筹满员人数','type'=>'unitstring','unit'=>'人','read'=>$isread,'help'=>'(<red>已上线的不能修改</red>)，考虑到《插件定制成本》(<red>插件定制成本=众筹价格*满额人数</red>)！'),
			array('name'=>'price','title'=>'上线价格','type'=>'unitstring','unit'=>'元','read'=>$isread,'help'=>'(<red>已上线的不能修改</red>)'),
			array('type'=>'text','name'=>'content','title'=>'插件需求简单说明','help'=>'业务逻辑越清晰，客户参与众筹热点越高！'),
			array('type'=>'images','name'=>'hdp','title'=>'插件需求配图','help'=>'插件配图越美，客户参与众筹热点越高！'),
			array('type'=>'upfile','name'=>'pdf','title'=>'需求文档','help'=>'带上需求文档，客户参与众筹热点更高！'),
		),
	);
	exi($return);
}
if($_RQ['op']=='help'){
	$item=cloud_request('cloud.bindgame.item');
	$item=json_decode($item,true);
	$item['bindfans']=$item['fans']['uniacid']?'已绑定':'未绑定';
	$item['bindwechat']=$item['fans']['follow']?'已关注':'未关注';
	$_SESSION['bindmobile']=$item['bindmobile'];
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'look',
		'desc'=>'赚积分攻略',
		'tabs'=>array(
			array('op'=>'mylist','title'=>'返回工单列表'),
		),
		'look'=>array(
			array('type'=>'tip','title'=>'如何赚取积分？赚取的积分，有什么用？积分可1:1用于购买进云市场大部分应用（加入了联盟的）！'),
			array('type'=>'string','name'=>'web.credit','title'=>'当前余额'),
			array('type'=>'string','name'=>'web.credit1','title'=>'当前积分'),
			array('type'=>'modal','plugin'=>'core','action'=>'account.workerline','op'=>'bindmobile','name'=>'mobile','title'=>'绑定手机','btntitle'=>'点击绑定','help'=>'绑定手机的,可获取大量积分'),
			array('type'=>'modal','plugin'=>'core','action'=>'account.workerline','op'=>'bindfans','name'=>'bindfans','title'=>'绑定微信粉丝','btntitle'=>'点击绑定','help'=>'绑定微信粉丝,可获取少量积分'),
			array('type'=>'modal','plugin'=>'core','action'=>'account.workerline','op'=>'bindwechat','name'=>'bindwechat','title'=>'关注微信公众号','btntitle'=>'点击关注','help'=>'关注微信公众号,可获取适量积分'),
			array('type'=>'modal','plugin'=>'core','action'=>'account.workerline','op'=>'olduser','name'=>'oldcredit1','title'=>'老会员回馈','btntitle'=>'点击领取','help'=>'老会员，定期会根据注册时间，回馈积分，越老的会员，回馈积分越多！'),
			array('type'=>'href','url'=>'core/account.workerline/','title'=>'发工单赚取积分','btntitle'=>'去发工单','help'=>'发工单可赚取积分，BUG真实存在，每个BUG奖励积分2-5个不等（一个工单多个BUG会做累计）'),
		),
	);
	$return['ways']=array('问题未解决','产生新问题','部分未解决');
	exi($return);
}
if($_RQ['op']=='kefu'){
	$item=cloud_request('cloud.bindgame.kefu');
	$item=json_decode($item,true);
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'look',
		'desc'=>'联系客服',
		'tabs'=>array(
			array('op'=>'mylist','title'=>'返回工单列表'),
		),
		'look'=>array(
			array('type'=>'tip','title'=>'目前主要两种在线客服模式：1、企业微信客服；2、企业微信客户群'),
			array('type'=>'image','width'=>'180','name'=>'kefuewm','title'=>'企业微信客服二维码','help'=>'用企业微信扫描上面二维码！'),
			array('type'=>'image','width'=>'180','name'=>'kefuqunewm','title'=>'企业微信客户群二维码','help'=>'用企业微信扫描上面二维码！'),
		),
	);
	exi($return);
}
if($_RQ['op']=='bindmobile'){
	$item['mobile']=$_SESSION['bindmobile'];
	$url=base64_encode('core/web.web/get/');
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'look',
		'desc'=>'绑定手机',
		'look'=>array(
			array('type'=>'href','url'=>'core/cloud.store//url='.$url,'title'=>'绑定手机','btntitle'=>'去绑定','help'=>'前往绑定手机号！'),
		),
	);
	exi($return);
}
if($_RQ['op']=='bindfans'){
	$item['bindfansurl']='http://s.jinyunweb.com/manage/index.php?plugin=core&action=web.web&op=bind';
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'look',
		'desc'=>'绑定微信粉丝',
		'look'=>array(
			array('type'=>'ewm','name'=>'bindfansurl','title'=>'微信扫二维码绑定粉丝'),
		),
	);
	exi($return);
}
if($_RQ['op']=='bindwechat'){
	$item['bindwechaturl']='http://weixin.qq.com/q/02_eRQooc3d1i10000g03k';
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'look',
		'desc'=>'关注微信公众号',
		'look'=>array(
			array('type'=>'ewm','name'=>'bindwechaturl','title'=>'微信扫二维码关注公众号'),
		),
	);
	exi($return);
}
if($_RQ['op']=='olduser'){
	$item['olduserurl']='http://s.jinyunweb.com/manage/index.php?plugin=core&action=web.web&op=helpcredit1';
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'look',
		'desc'=>'前往领取',
		'look'=>array(
			array('type'=>'ewm','name'=>'olduserurl','title'=>'微信扫二维码领取'),
		),
	);
	exi($return);
}
if($_RQ['op']=='upend'){
	$id=intval($_RQ['id']);
	$result=cloud_request('cloud.workerline.upend',array('id'=>$id));
	exi('提交成功！');
}
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	$result=cloud_request('cloud.workerline.del',array('id'=>$id));
	exi('删除成功！','','mylist');
}
if($_RQ['op']=='yudingdel'){
	$id=intval($_RQ['id']);
	$result=cloud_request('cloud.workerline.yudingdel',array('id'=>$id));
	exi('删除成功！','','yuding');
}